/*
 * Copyright (C) 2010-2011 Graz University of Technology, Austria. All Rights reserved. 
 *
 * Contact: Simone Kopeinik <simone.kopeinik@tugraz.at>
 * 	   Graz University of Technology, Knowledge Management Institute, Brückenkopfgasse 1/6, 8020 Graz 	
 * 	   <http://www.kmi.tugraz.at/>
 * 
 * This software is part of the TARGET platform developed by the
 * TARGET EC-funded project www.reachyourtarget.org
 *
 * This software is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, version 3.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * The GNU General Public License is available at <http://www.gnu.org/licenses/>.
 *
 */
package at.tugraz.kmi.css.cbkst2.prereq;

import at.tugraz.kmi.css.cbkst2.CbKSTVertex;
import at.tugraz.kmi.css.cbkst2.ImmutablePrerequesiteOrderSet;
import at.tugraz.kmi.css.cbkst2.PrerequesiteRelation;

import com.google.common.collect.ImmutableSet;
import com.google.inject.Inject;

import edu.uci.ics.jung.graph.ObservableGraph;

/**
 * A delegate that allows to observe the underlying
 * 
 * @author Georg Öttl
 * 
 * @param <V>
 * @param <E>
 */
public final class JungObservablePrerequesiteGraph<V extends CbKSTVertex, E extends PrerequesiteRelation>
		extends ObservableGraph<V, E> implements
		PrerequesiteOrderSetGraph<V, E> {

	private static final long					serialVersionUID	= 1L;
	private final JungPrerequesiteGraph<V, E>	graph;

	/**
	 * @param graph
	 *            The graph to observe
	 */
	@Inject
	JungObservablePrerequesiteGraph(JungPrerequesiteGraph<V, E> graph) {
		super(graph);
		this.graph = graph;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean containsPrerequesite(PrerequesiteRelation prerequisite) {
		return graph.containsPrerequesite(prerequisite);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ImmutableSet<V> getDescendants(V vertex) {
		return graph.getDescendants(vertex);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ImmutableSet<V> getCbKSTVertices() {
		return graph.getCbKSTVertices();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean addPrerequesite(PrerequesiteRelation prerequisite) {
		return graph.addPrerequesite(prerequisite);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean removePrerequesite(PrerequesiteRelation prerequisite) {
		return graph.removePrerequesite(prerequisite);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void addAll(ImmutablePrerequesiteOrderSet<V> set) {
		graph.addAll(set);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean contains(V vertex) {
		return graph.contains(vertex);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public int size() {
		return graph.size();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ImmutableSet<V> getPrerequisites(V vertex) {
		return graph.getPrerequisites(vertex);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ImmutableSet<PrerequesiteRelation> getPrerequisites() {
		return graph.getPrerequisites();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ObservableGraph<V, E> getTransitiveClosureGraph() {
		return graph.getTransitiveClosureGraph();
	}

	@Override
	public boolean add(V vertex) {
		return addVertex(vertex);
	}

	@Override
	public V find(String id) {
		return graph.find(id);
	}

}
